﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Site.Secure
{
    public partial class Remove_User : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["userType"].ToString() == "admin" || Session["userType"].ToString() == "root")
                {
                    SqlDataSource1.DeleteCommand = "DELETE FROM Users WHERE userID='" + DropDownList1.Text + "'";
                    SqlDataSource1.Delete();
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('You are not allowed to add users, please login with an account that has full root access')</SCRIPT>");
                }
            }
            catch
            {
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Your session has expired, this means that you can not perform any root tasks on this website. Please login again or restart your browser and navigate back to this page.')</SCRIPT>");
            }
        }
    }
}